package com.scnu.yxp.picture.tool;

import java.awt.Graphics;
import java.awt.event.MouseEvent;
import com.scnu.yxp.picture.PictureFrame;

public class PencilTool extends AbstractTool{
	private static Tool tool = null;
	
	private PencilTool(PictureFrame frame)
	{
		super(frame, "img/pencilcursor.gif");
	}

	public static Tool getInstance(PictureFrame frame) {
		if(tool == null){
			tool = new PencilTool(frame);
		}
		return tool;
	}

	public void mouseDragged(MouseEvent e)
	{
		super.mouseDragged(e);
		Graphics g = getFrame().getBufferedImage().getGraphics();
		if (getPressX() > 0 && getPressY() > 0) {
			g.setColor(AbstractTool.color);
			g.drawLine(getPressX(), getPressY(), e.getX(), e.getY());
			setPressX(e.getX());
			setPressY(e.getY());
			getFrame().getDrawSpace().repaint();
		}
	}
}
